package com.zhang.learn.spring.springplugin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author zhanghaolian
 * @date 2021/6/7 0:20
 */
@Component
public class CustomerService {
    @Autowired
    private PluginRegistry<MobileIncrementBusiness,MobileCustomer> mobileCustomerPluginRegistry;


    public void increments(MobileCustomer mobileCustomer,int money){
        //获取插件
        List<MobileIncrementBusiness> plugins=mobileCustomerPluginRegistry.getPlugins();
        for (MobileIncrementBusiness incrementBusiness:plugins){
            //对人员进行充值
            incrementBusiness.increment(mobileCustomer,money);
        }
    }
}
